//
//  MumaView.swift
//  SkyApp
//
//  Created by 白翊 on 2021/12/29.
//

import UIKit

class MumaView: UICollectionViewCell {

    override init(frame: CGRect) {
        super.init(frame: frame)
        
        contentView.addSubview(picture)
        picture.snp.makeConstraints { make in
            make.center.equalTo(contentView)
            make.size.equalTo(contentView).multipliedBy(0.5)
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    var display: MumaDisplay? {
        didSet {
            guard let display = display else {
                return
            }

            picture.image = UIImage(named: display.isFlower ? "icon_muma_hua" : "icon_muma")
            
            if display.isUp {
                picture.transform = .identity
            }else {
                picture.transform = .init(rotationAngle: .pi)
            }
        }
    }
    
    lazy var picture = UIImageView(contentMode: .scaleAspectFit)
}
